package bach.job;

import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import com.xunlei.netty.httpserver.cmd.BaseCmd;
import com.xunlei.netty.httpserver.component.XLHttpRequest;
import com.xunlei.netty.httpserver.component.XLHttpResponse;
import com.xunlei.netty.httpserver.component.XLHttpResponse.ContentType;
import com.xunlei.spring.Config;
import com.xunlei.util.Log;
import com.xunlei.util.concurrent.BaseJob;
import com.xunlei.util.concurrent.ConcurrentUtil;

@Service
public class TestJobCmd extends BaseCmd {

    private static final Logger log = Log.getLogger();
    @Config(resetable = true)
    private int nodesNumberOfFamousUser = 3;

    private BaseJob job = new BaseJob(log) {

        @Override
        public void process() throws Throwable {
        }
    };

    public Object process(XLHttpRequest request, XLHttpResponse response) throws Exception {
        response.setInnerContentType(ContentType.plain);
        Future<?> future = ConcurrentUtil.getDaemonExecutor().submit(job);
        future.get();
        return "OK";
    }
}
